package httpsproxy

import (
	"io"
	"log"
	"net"
)

type tranfer struct {
	cConn net.Conn
	sConn net.Conn
}

func (t *tranfer) transfer() {
	go t.copy2Client()
	go t.copy2Server()
}

func (t *tranfer) copy2Client() {
	defer func() {
		if err := recover(); err != nil {
			log.Print(err)
		}
	}()
	buffer := make([]byte, 1024)
	_, _ = io.CopyBuffer(t.cConn, t.sConn, buffer)
}

func (t *tranfer) copy2Server() {
	defer func() {
		if err := recover(); err != nil {
			log.Print(err)
		}
	}()
	buffer := make([]byte, 1024)
	_, _ = io.CopyBuffer(t.sConn, t.cConn, buffer)
}
